﻿using ChannelNamesParsingModule.Service;
using ChannelNamesParsingModule.Views;
using Prism.Common.Interfaces;
using Prism.Common.RegionNames;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;

namespace ChannelNamesParsingModule.Modules
{
	public class Module : IModule
	{
		protected readonly IRegionManager _regionManager;

		protected readonly IUnityContainer _container;

		public Module( IRegionManager regionManager, IUnityContainer container )
		{
			_regionManager = regionManager;
			_container = container;
		}

		public void Initialize()
		{
			_regionManager.RegisterViewWithRegion(
				RegionNames.ChannelNamesParsingRegionName,
				typeof( Main ) );

			// Register as singleton:
			_container.RegisterType<IEvaluateLogChannelsService, EvaluateLogChannelsService>( new ContainerControlledLifetimeManager() );
		}
	}
}
